<?php
/**
 * @file : celebrityinfo.php
 * @date : 2014-12-27
 */
namespace haibao\cms\data;

use haibao\cms\model\filter\CelebrityInfo as CelebrityInfoFilter;

class CelebrityInfo extends \haibao\cms\data\BaseMysql{

    public function __construct(){
        parent::__construct('\haibao\cms\model\data\CelebrityInfo');
    }

    /**
     * 添加明星详细信息
     * @param : Object \haibao\cms\model\data\CelebrityInfo $model
     */
    public function addCelebrityInfo($model){

        try{
        
           $this->add($model); 
        
        } catch( \Exception $e){
        
            throw $e;
        }
    }

    /**
     * 根据明星ID获取明星详细信息
     * @param Int $celebrityId 明星ID
     */
    public function getCelebrityInfoByCelebrityId($celebrityId){

        $filter = new CelebrityInfoFilter();
        $filter->select(array(
            CelebrityInfoFilter::CONDITION_FIELD_NAME_MORE_CH_NAME,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_MORE_EH_NAME,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_DIE_DATE,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_XING_ZUO,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_BIRTH_PLACE,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_HEIGHT,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_BLOOD,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_SCHOOL,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_EC_COMPANY,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_REP_WORKS,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_SUCCESS,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_FAMILY,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_VIDEO_IMAGE_ID,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_VIDEO_URL,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_CELEBRITY_ID,
        	CelebrityInfoFilter::CONDITION_FIELD_NAME_VIDEO_IMAGE_ID,
        	CelebrityInfoFilter::CONDITION_FIELD_NAME_VIDEO_URL,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_INSTAGRAM_URL,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_BLOG_URL,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_MIRCO_URL,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_OFFICE_WEB,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_LOOKBOOK,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_FACEBOOK,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_TWITTER,
            CelebrityInfoFilter::CONDITION_FIELD_NAME_COUNTRY,
        ));
        $filter->where(CelebrityInfoFilter::CONDITION_FIELD_NAME_CELEBRITY_ID,\haibao\frame\data\query\Condition::CONDITION_EQUAL,$celebrityId);
        return $this->getOne($filter);
    }
    
    public function UpdateCelebrityInfo($queryArr){
    	$sql = "update CelebrityInfo set VideoImageId=%s,VideoUrl=%s where CelebrityId=%s";
    	$sqlCelebrity = "update Celebrity set UpdateTime=%s where Id=%s";
    	$this->query($sql,$queryArr);
    	$this->query($sqlCelebrity,array(date('Y-m-d H:i:s'),$queryArr[2]));
    }
}
